//
//  BaseTableViewController.m
//  王雷Sinoweibo
//
//  Created by wanglei on 16/10/20.
//  Copyright © 2016年 wanglei. All rights reserved.
//

#import "BaseTableViewController.h"
#import "VisitorLoginView.h"
#import "OAuthViewController.h"
#import <UIKit/UIKit.h>

@interface BaseTableViewController ()<VisitorLoginViewDelegate,UITableViewDelegate,UITableViewDataSource>

@end

@implementation BaseTableViewController

- (void)userWillLogin;{
    
    NSLog(@"userWillLogin");
    [self presentToOauther];
}
- (void)userWillRegister;{
    
    NSLog(@"userWillRegister");
}

//纯代码创建控制器的方法入口
-(void)loadView{
    
       self.isUserLogin = false;
    
    if (_isUserLogin) {
        [super loadView];
    }else{
        VisitorLoginView *loginView1 = [[VisitorLoginView alloc]init];
        
#pragma mark :注意此处的把loginView赋值给self.loginView很有必要
        self.loginView = loginView1;
        
//        注意此处代理对象的设置,self在此处是代理者,loginView1是委托者
        loginView1.delegate = self;

//      self.loginview将来要调用setupInfoWith'''那个方法,这样才能将视图转换过来
        self.view = _loginView;
    }
    
   }


-(void)viewDidAppear:(BOOL)animated{
    UIBarButtonItem *leftbarbuttonitem = [[UIBarButtonItem alloc]initWithTitle:@"登录" style:UIBarButtonItemStylePlain target:self action:@selector(userWillLogin)];
    
    [self.navigationItem setLeftBarButtonItem:leftbarbuttonitem animated:YES];
    
    
    UIBarButtonItem *rightbarbuttonitem = [[UIBarButtonItem alloc]initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(userWillRegister)];
    
    [self.navigationItem setRightBarButtonItem:rightbarbuttonitem animated:YES];
    
  
    
}

- (void)presentToOauther{
    OAuthViewController *controller = [[OAuthViewController alloc]init];
    UINavigationController *navcontroller = [[UINavigationController alloc]initWithRootViewController:controller];
    [self presentViewController:navcontroller animated:YES completion:nil];
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
    return 0;
}

/*
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
 
 // Configure the cell...
 
 return cell;
 }
 */

/*
 // Override to support conditional editing of the table view.
 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the specified item to be editable.
 return YES;
 }
 */

/*
 // Override to support editing the table view.
 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
 if (editingStyle == UITableViewCellEditingStyleDelete) {
 // Delete the row from the data source
 [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
 } else if (editingStyle == UITableViewCellEditingStyleInsert) {
 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
 }
 }
 */

/*
 // Override to support rearranging the table view.
 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
 }
 */

/*
 // Override to support conditional rearranging of the table view.
 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the item to be re-orderable.
 return YES;
 }
 */

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
